from typing import List


class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        if not prices:
            return 0
        res = 0
        min_value = prices[0]
        for i in range(len(prices)):
            min_value = min(min_value, prices[i])
            res = max(res, prices[i] - min_value)
        return res


assert Solution().maxProfit([1, 2, 3, 4, 5, 0, 10]) == 10
assert Solution().maxProfit([7, 1, 5, 3, 6, 4]) == 5

